﻿Imports System.Linq
Partial Class App_FollowersList
    Inherits MyUI.PageBaseApp

    Public CurrAccount As mDB.Account

    Public WithEvents gg As UI.GroupButton(Of Button)
    'Protected SortGridQuery, SortGridFollStaus As UI.SortControl

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

        gg = New UI.GroupButton(Of Button)(Me.ViewState, "GROUP_SEARCH", "active")
        'SortGridFollStaus = New UI.SortControl(Me.GridFollowStatus.ID, Me.ViewState, "update_status_date", SortDirection.Descending)

        'Me.pp.g = Me.GridUsers
        'Me.pp2.g = Me.repuser

        CurrAccount = CurrUser.CurrAccount

        If Not Me.IsPostBack Then
            Me.gg.SelectButton = Me.RbtSearchLink
            SetDataPage()
        End If

    End Sub

    Private Sub SetDataPage()

        'SetListAccount()

        If CurrAccount IsNot Nothing Then
            SetDataConsole()
            SetDataAccountFilter()
            SetDataAccountList()
        End If

    End Sub

    Private Sub SetDataConsole()

        'UI.Controls.ClassSet(Me.RbtSearchLink, "active", Me.SearchType = 1)
        'UI.Controls.ClassSet(Me.RbtSearchCategory, "active", Me.SearchType = 2)
        'UI.Controls.ClassSet(Me.RbtSearchHashtag, "active", Me.SearchType = 3)


        Dim Cat = CurrAccount.
            Tab_Categorize_Follower.
            REL.Categorize_Follower.categorize.
            SetSelect("Categorize.*").
        ToDataTable()
        UI.List.Bind(Me.DdlCategories, Cat, "description", "id", "", False)

        Dim link = MyApp.EnumToDic(Of mDB._Account_Link.Type)()
        UI.List.Bind(Me.DdlLinkType, link, "value", "key", "", False)
        UI.List.Bind(Me.DdlLinkType2, link, "value", "key", "", False)

        'Dim hashtag = CurrUser.Tab_Query.BY.Query.Real_Time(1).SetSelect("query.*").ToDataTable
        Dim hashtag = CurrAccount.Tab_Query_Listen.ToDataTable ' CurrAccount.Tab_Listen_Query.REL.Listen_Query.Query.SetSelect("query.*").ToDataTable
        UI.List.Bind(Me.DdlHashtag, hashtag, "query", "id", "", False)

        Dim AutoFollStatus = MyApp.EnumToDic(Of mDB.Auto_Follow_Account.StatusType)()
        UI.List.Bind(Me.DdlAutoFollStatus, AutoFollStatus, "value", "key", "", False)

        Dim query = CurrAccount.View_Query_AutoFollow.ToDataTable  'CurrAccount.Tab_Auto_Follow_Query.REL.Auto_Follow_Query.Query.SetSelect("query.id", "query.query").ToDataTable
        UI.List.Bind(Me.DdlAutoFollQuery, query, "query", "id", "", False)

        Dim gender = MyApp.EnumToDic(Of mDB.Gender_Name.Type)()
        gender.Remove(mDB.Gender_Name.Type.NOT_ASSIGNED)
        UI.List.Bind(Me.DdlGender, gender, "value", "key", "", False)

        Dim lang = DB.TAB.Language.ToList
        UI.List.Bind(Me.DdlLanguage, lang, "language", "lang_code", "", False)
        UI.List.Bind(Me.DdlLanguageNot, lang, "language", "lang_code", "", False)

        Dim business = MyApp.EnumToDic(Of mDB.Account.BusinessType)()
        business.Remove(mDB.Account.BusinessType.NOT_ASSIGNED)
        UI.List.Bind(Me.DdlBusiness, business, "value", "key", "", False)

        Dim Status = MyApp.EnumToDic(Of mDB.Account.StatusType)()
        Status.Remove(mDB.Account.StatusType.NOT_ASSIGNED)
        UI.List.Bind(Me.DdlStatus, Status, "value", "key", "", False)




    End Sub

    Private Sub SetDataAccountFilter()

        Dim f = CurrAccount.Tab_Account_Filter.ToDataTable
        UI.List.Bind(Me.DdlAccountFilter, f, "description", "id", "", False)
        Me.DdlAccountFilter.Items.Insert(0, New ListItem("-- Select  --", "0"))

    End Sub

    'Public Property SearchType() As String
    '    Get
    '        Return Me.ViewState("report_day")
    '    End Get
    '    Set(ByVal value As String)
    '        ViewState("report_day") = value
    '    End Set
    'End Property

    'Public Function Filter() As MyDBase.mDB.BuildQuery(Of mDB.Account)

    '    Dim q = DB.TAB.Account.
    'REL.Account.Account_Link.
    'REL.Account.Account_Add_Info.
    'REL.Account.Account_Update

    '    Dim idsLink = UI.List.GetSelectValues(Me.DdlLinkType).Select(Function(o) DirectCast(CInt(o), mDB.Account_Link.Type)).ToList
    '    If idsLink.Count <> 0 Then
    '        q.BY.Account_Link.Account_Id(CurrAccount.Id, idsLink)
    '    Else
    '        q.BY.Account_Link.Account_Id(CurrAccount.Id)
    '    End If

    '    Dim idscat = UI.List.GetSelectValues(Me.DdlCategories).Select(Function(o) CInt(o)).ToList
    '    If idscat.Count <> 0 Then
    '        q.REL.Account.Categorize_Account()
    '        q.BY.Categorize_Account.Account_Id(CurrAccount.Id, idscat)
    '    End If

    '    Dim idsLang = UI.List.GetSelectValues(Me.DdlLanguage)
    '    If idsLang.Count <> 0 Then
    '        q.Where("lang", "IN", idsLang)
    '    End If

    '    Dim idsgend = UI.List.GetSelectValues(Me.DdlGender).Select(Function(o) CInt(o)).ToList
    '    If idsgend.Count <> 0 Then
    '        q.Where("gender_type_id", "IN", idsgend)
    '    End If

    '    Dim idsBusin = UI.List.GetSelectValues(Me.DdlBusiness).Select(Function(o) CInt(o)).ToList
    '    If idsBusin.Count <> 0 Then
    '        q.Where("business_type_id", "IN", idsBusin)
    '    End If

    '    'If FromDate > Date.MinValue Then
    '    '    q.Where("create_date", ">=", FromDate)
    '    'End If

    '    'If ToDate > Date.MinValue Then
    '    '    q.Where("create_date", "<", ToDate.AddDays(1))
    '    'End If

    '    Return q

    'End Function

    Private Sub SetDataAccountList()

        Dim dt As DataTable = Nothing

        Me.GridUsers.PageSize = 20
        UI.Grid.Bind(Me.GridUsers, dt)

        Me.GridAccount.PageSize = 50
        UI.Grid.Bind(Me.GridAccount, dt)

        Me.GridFollowStatus.PageSize = 30
        UI.Grid.Bind(Me.GridFollowStatus, dt)

        Me.GridFollowSummary.PageSize = 100
        UI.Grid.Bind(Me.GridFollowSummary, dt)

        Me.GridMessage.PageSize = 20
        UI.Grid.Bind(Me.GridMessage, dt)

        Me.LblUserFound.Text = "-"

        Dim FromDate = Utils.Conv.ToDate(Me.TxtBeginDate.Text)
        Dim ToDate = Utils.Conv.ToDate(Me.TxtEndDate.Text)

        Me.PnlSearchAutoFollow.Visible = False
        Me.PnlSearchHashtag.Visible = False
        Me.PnlSearchLink.Visible = False
        Me.chart_div_post_send.Visible = False
        Me.TxtFullname.Enabled = True
        Me.TxtUsername.Enabled = True

        Select Case Me.gg.SelectValue
            Case 1
                Me.PnlSearchLink.Visible = True

                dt = CurrAccount.View_AccountLink_ByFilter(Me.GetDataFilter).
                    Limit(1000).
                ToDataTable()
                'GroupBy("account.id").

                UI.Grid.Bind(Me.GridUsers, dt)

                'UI.Rep.Bind(Me.repuser, dt)
                'Me.repuser.DataSource = dt
                'Me.repuser.DataBind()


            Case 2
                'Me.PnlSearchCategory.Visible = True
                Dim q = DB.TAB.Account.
                    REL.Account.Account_Add_Info.
                    REL.Account.Account_Update.
                    REL.Account.Categorize_Account

                Dim ids = (From i In Me.DdlCategories.GetSelectedIndices Select CInt(Me.DdlCategories.Items(i).Value)).ToList

                If ids.Count <> 0 Then
                    q.BY.Categorize_Account.Account_Id(CurrAccount.Id, ids)
                Else
                    q.BY.Categorize_Account.Account_Id(CurrAccount.Id)
                End If

                dt = q.
                    GroupBy("account.id").
                ToDataTable()

                UI.Grid.Bind(Me.GridUsers, dt)





            Case 3
                Me.PnlSearchHashtag.Visible = True
                Me.TxtFullname.Enabled = False
                Me.chart_div_post_send.ClientIDMode = Web.UI.ClientIDMode.Static
                Me.chart_div_post_send.Visible = True

                If FromDate = Date.MinValue Then
                    FromDate = Now.AddDays(-15).Date
                End If
                If ToDate = Date.MinValue Then
                    ToDate = Now.Date
                End If

                Dim qQueries = CurrAccount.Tab_Query_Listen     'CurrUser.Tab_Query.BY.Query.Real_Time(1)
                Dim ids = UI.List.GetSelectValuesInt(Me.DdlHashtag) '   (From i In Me.DdlHashtag.GetSelectedIndices Select CInt(Me.DdlHashtag.Items(i).Value)).ToList
                If ids.Count <> 0 Then
                    qQueries.Where("query.id", "IN", ids)
                End If
                'Dim queries = qQueries.ToList

                Dim gruppo = New mDB.Group_Query(qQueries.ToList)

                If gruppo.QueryList.Count > 0 Then

                    'Dim qgruppo = gruppo.FilterAccount(FromDate, ToDate, Me.TxtUsername.Text).
                    '    GroupBy("account_code").OrderBy("Post_count desc").
                    '    SetSelect("account_username", "account_code", "sum(Post_count) as Post_count", "account_follower_count")

                    'Dim qfinal = DB.GetQuery.From(qgruppo, "aaa", "")

                    'qfinal.Join("account", "account_code", "aaa.account_code").
                    'Join("account_link", "account_link_id", "account.id")

                    'dt = qfinal.
                    '    SetSelect("aaa.*", "create_date").
                    'ToDataTable()

                    dt = gruppo.View_Account_Search(FromDate, ToDate, Me.TxtUsername.Text).
                        GroupBy("account_code").OrderBy("Post_count desc").
                        SetSelect("account_username", "account_code", "sum(Post_count) as Post_count", "account_follower_count").
                    ToDataTable()
                End If



                UI.Grid.Bind(Me.GridAccount, dt)

                '-------------------------------------
                ' CHART

                'Dim t1 = mDB._Query_Account.GetTrendAccount(queries, FromDate, ToDate)
                Dim t1 = gruppo.GetTrendAccount(FromDate, ToDate)

                Dim DataChart As New List(Of Object())
                DataChart.Add({"data", "post", "impression"})
                For ct = 0 To t1.Count - 1
                    DataChart.Add({MyUI.Print.DateMonthDay(t1(ct).Post_Update), t1(ct).Post_Count, t1(ct).Account_Follower_Count})
                Next

                Dim json = MyApp.JSONSerialize(New With {
                    .data = DataChart
                })

                Me.AddJScript(SF("DrawChartPostSend({0});", json))

            Case 4
                Me.PnlSearchAutoFollow.Visible = True
                Me.TxtFullname.Enabled = False

                Dim q = CurrAccount.Tab_Auto_Follow_Account

                '                    REL.Auto_Follow_Account.Account_Code.

                Dim ids = (From i In Me.DdlAutoFollStatus.GetSelectedIndices Select CInt(Me.DdlAutoFollStatus.Items(i).Value)).ToList
                Dim idsq = (From i In Me.DdlAutoFollQuery.GetSelectedIndices Select CInt(Me.DdlAutoFollQuery.Items(i).Value)).ToList

                If ids.Count <> 0 Then
                    q.Where("status_id", "IN", ids)
                End If

                If idsq.Count <> 0 Then
                    q.Where("source_id", "IN", idsq)
                End If

                If FromDate > Date.MinValue Then
                    q.Where("update_status_date", ">=", FromDate)
                End If

                If ToDate > Date.MinValue Then
                    q.Where("update_status_date", "<", ToDate.AddDays(1))
                End If

                If Me.TxtUsername.Text <> "" Then
                    q.Where("account_to_foll_username", "like", SF("%{0}%", Me.TxtUsername.Text))
                End If

                Dim qsum = q.Clone

                'dt = SortGridFollStaus.SortQuery(q).
                'ToDataTable()

                dt = pp3.SortQuery(q).
                ToDataTable()

                UI.Grid.Bind(Me.GridFollowStatus, dt)

                Dim g = Me.GridFollowStatus


                For Each gr As GridViewRow In g.Rows
                    Dim dr = dt(UI.GridRow.GetIndexData(gr))
                    Dim LblStatus = UI.GridRow.GetControl(Of Label)(gr, "LblStatus")

                    Dim Status = DirectCast(dr("status_id"), mDB.Auto_Follow_Account.StatusType)

                    Select Case Status
                        Case mDB.Auto_Follow_Account.StatusType.PENDING, mDB.Auto_Follow_Account.StatusType.FOLLOW
                            LblStatus.ForeColor = Drawing.Color.Orange

                        Case mDB.Auto_Follow_Account.StatusType.ALREADY_FRIEND, mDB.Auto_Follow_Account.StatusType.UNFOLLOW
                            LblStatus.ForeColor = Drawing.Color.Red

                        Case mDB.Auto_Follow_Account.StatusType.ERROR
                            LblStatus.ForeColor = Drawing.Color.Gray

                        Case Else
                            LblStatus.ForeColor = Drawing.Color.Green

                    End Select


                    LblStatus.Text = Status.ToString

                Next

                Dim dtSum = qsum.
                    Where("status_id", "IN", New List(Of Integer) From {mDB.Auto_Follow_Account.StatusType.BECOME_FOLLOWER, mDB.Auto_Follow_Account.StatusType.UNFOLLOW}).
                    GroupBy("source_type_id", "source_id").
                    Select(
                        "source_type_id", "source_id", "source_description",
                        "sum(if(status_id = " & mDB.Auto_Follow_Account.StatusType.BECOME_FOLLOWER & ",1,0)) as count_become_follower",
                        "sum(if(status_id = " & mDB.Auto_Follow_Account.StatusType.UNFOLLOW & ",1,0)) as count_unfollower"
                    ).
                ToDataTable()


                Utils.DT.ComputeData.Compute(dtSum, "tot", " ({'count_become_follower'} + {'count_unfollower'})")
                Utils.DT.ComputeData.Compute(dtSum, "perc", "{'count_become_follower'} / {'tot'}  * 100 ")
                Utils.DT.ComputeData.Compute(dtSum, "seg", " {'tot'} / {p0} * 100 ", "=sum(tot)")

                dtSum.DefaultView.Sort = "perc desc"

                UI.Grid.Bind(Me.GridFollowSummary, dtSum)


            Case 5

                Dim q = DB.TAB.Message_Post.
                    Join("message_post", "post_code", "message_post.reply_to_post_code", "mess_reply", "").
                    Join("account", "id", "mess_reply.account_id").
                    Where("message_post.account_id", "=", CurrAccount.Id).
                    Where("message_post.reply_to_post_code", "<>", "").
                    OrderBy("pubb_date desc").
                    SetSelect("Message_Post.*", "account.*", "mess_reply.post_text as  reply_post_text")


                dt = q.
                ToDataTable()



                UI.Grid.Bind(Me.GridMessage, dt)

        End Select




        If dt IsNot Nothing Then
            Me.LblUserFound.Text = IIf(dt.Rows.Count >= 1000, "999+", dt.Rows.Count)
        End If

        Me.UpPUser.Update()

    End Sub

    'Protected Sub repuser_DataBinding(sender As Object, e As EventArgs) Handles repuser.DataBinding

    '    'Dim dt As DataTable = sender.datasource


    '    'sender.datasource = From dr In dt.DefaultView Skip 20 Take 20




    'End Sub


    Protected Sub GridUsers_DataBinding(sender As Object, e As EventArgs) Handles GridUsers.DataBinding


    End Sub
    'Protected Sub repuser_PagePropertiesChanging(sender As Object, e As PagePropertiesChangingEventArgs) Handles repuser.PagePropertiesChanging
    '    '    Me.reppager.SetPageProperties(e.StartRowIndex, e.MaximumRows, False)


    '    SetDataAccountList()

    'End Sub

    'Protected Sub pp2_Load(p As Integer) Handles pp2.PageChanged
    '    SetDataAccountList()
    'End Sub

    Protected Sub pp_Load() Handles pp.PageChanged
        SetDataAccountList()
    End Sub
    Protected Sub pp3_Load() Handles pp3.PageChanged
        SetDataAccountList()
    End Sub

    Protected Sub GridUsers_PageIndexChanging(sender As Object, e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridUsers.PageIndexChanging

        'Me.GridUsers.PageIndex = e.NewPageIndex

        SetDataAccountList()

    End Sub
    Protected Sub GridAccount_PageIndexChanging(sender As Object, e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridAccount.PageIndexChanging

        Me.GridAccount.PageIndex = e.NewPageIndex

        SetDataAccountList()

    End Sub
    'Protected Sub GridFollowStatus_PageIndexChanging(sender As Object, e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridFollowStatus.PageIndexChanging

    '    GridFollowStatus.PageIndex = e.NewPageIndex

    '    Me.SetDataAccountList()
    'End Sub
    Protected Sub GridFollowStatus_Sorting(sender As Object, e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GridFollowStatus.Sorting

        Me.pp3.Sort(e.SortExpression)
        'Me.SortGridFollStaus.Sort(e.SortExpression)

        Me.SetDataAccountList()

    End Sub


    Protected Sub BtnExport_Click(sender As Object, e As EventArgs) Handles BtnExport.Click

        SetDataAccountList()

    End Sub


    'Protected Sub RbtSearchLink_Click(sender As Object, e As EventArgs) Handles RbtSearchLink.Click, RbtSearchCategory.Click, RbtSearchHashtag.Click

    '    Me.SearchType = sender.commandargument

    '    Me.SetDataConsole()

    'End Sub

    Protected Sub gg_onselected(value As String) Handles gg.Selected
        SetDataAccountList()
    End Sub

    'Public Function GetSelectValues(l As ListBox) As List(Of String)

    '    Return (From i In l.GetSelectedIndices Select l.Items(i).Value).ToList


    'End Function

    Protected Sub BtnAddFilter_Click(sender As Object, e As EventArgs) Handles BtnAddFilter.Click

        Dim f = New mDB.Account_Filter With {
            .Account_Id = CurrAccount.Id, .Description = Me.TxtNewFilter.Text
        }

        f.Filter = Me.GetDataFilter

        DB.InsertOnSubmit(f)
        DB.SubmitChanges()

        'f.SaveFilter_Data()

        SetDataAccountFilter()

    End Sub

    Protected Sub DdlAccountFilter_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAccountFilter.SelectedIndexChanged
        Dim f = CurrAccount.Tab_Account_Filter.GetByPK(Me.DdlAccountFilter.SelectedValue)

        If f Is Nothing Then
            f = New mDB.Account_Filter
        End If

        SetDataFilter(f.Filter)

    End Sub

    Private Sub SetDataFilter(f As mDB.Account.Filter)

        Me.TxtUsername.Text = f.Username
        Me.TxtFullname.Text = f.Fullname
        Me.TxtBeginDate.Text = MyUI.Print.DateInput(f.FromDate)
        Me.TxtEndDate.Text = MyUI.Print.DateInput(f.ToDate)
        UI.List.SetSelectValues(Me.DdlLinkType, f.IdsLink)
        UI.List.SetSelectValues(Me.DdlBusiness, f.IdsBusin)
        UI.List.SetSelectValues(Me.DdlStatus, f.IdsStatus)
        UI.List.SetSelectValues(Me.DdlCategories, f.IdsCat)
        UI.List.SetSelectValues(Me.DdlGender, f.IdsGend)
        UI.List.SetSelectValues(Me.DdlLanguageNot, f.IdsLangNot)
        UI.List.SetSelectValues(Me.DdlLanguage, f.IdsLang)

    End Sub

    Private Function GetDataFilter() As mDB.Account.Filter

        Return New mDB.Account.Filter With {
            .FromDate = Utils.Conv.ToDate(Me.TxtBeginDate.Text), .ToDate = Utils.Conv.ToDate(Me.TxtEndDate.Text),
            .Username = Me.TxtUsername.Text, .Fullname = Me.TxtFullname.Text,
            .IdsLink = UI.List.GetSelectValuesInt(Me.DdlLinkType),
            .IdsBusin = UI.List.GetSelectValuesInt(Me.DdlBusiness),
            .IdsStatus = UI.List.GetSelectValuesInt(Me.DdlStatus),
            .IdsCat = UI.List.GetSelectValuesInt(Me.DdlCategories),
            .IdsGend = UI.List.GetSelectValuesInt(Me.DdlGender),
            .IdsLangNot = UI.List.GetSelectValues(Me.DdlLanguageNot),
            .IdsLang = UI.List.GetSelectValues(Me.DdlLanguage)
        }
    End Function


    Protected Sub BtnRemoveFilter_Click(sender As Object, e As EventArgs) Handles BtnRemoveFilter.Click

        CurrAccount.Tab_Account_Filter.ByPK(Me.DdlAccountFilter.SelectedValue).Delete.ExecuteCommand()

        SetDataAccountFilter()
    End Sub

    Protected Sub BtnSaveFilter_Click(sender As Object, e As EventArgs) Handles BtnSaveFilter.Click

        Dim f = CurrAccount.Tab_Account_Filter.GetByPK(Me.DdlAccountFilter.SelectedValue)

        f.Filter = Me.GetDataFilter
        DB.SubmitChanges()

        SetDataAccountFilter()

    End Sub




End Class

'Public Class GroupButton_old

'    Public Property CacheState As Object
'    Public Property group As String
'    Public Property cssactive As String


'    Private Buttons As New List(Of Button)
'    Private p As Page

'    Public ReadOnly Property SelectValue() As String
'        Get
'            Return Me.SelectButton.CommandArgument
'        End Get
'    End Property

'    Public Property SelectButtonID() As String
'        Get
'            Return Me.CacheState("_GROUP_" & Me.group)
'        End Get
'        Set(ByVal value As String)
'            Me.CacheState("_GROUP_" & Me.group) = value
'        End Set
'    End Property

'    Public Property SelectButton() As Button
'        Get
'            Return (From b In Me.Buttons Where b.ID = Me.SelectButtonID).FirstOrDefault
'        End Get
'        Set(value As Button)
'            Me.SelectButtonID = value.ID

'            SetDataButtonList()

'        End Set
'    End Property

'    Public Event Selected(value As String)


'    Sub New(cache As Object, group As String, cssactive As String)


'        Me.p = HttpContext.Current.CurrentHandler
'        Me.CacheState = cache
'        Me.group = group
'        Me.cssactive = cssactive

'        Buttons = UI.Controls.FindCommandControls(Of Button)(Me.p.Controls, group)

'        For Each b In Buttons
'            AddHandler b.Click, AddressOf BntExport_Click
'        Next
'        SetDataButtonList()

'    End Sub

'    Private Sub SetDataButtonList()

'        For Each b In Buttons
'            UI.Controls.ClassSet(b, cssactive, b.ID = Me.SelectButtonID)
'        Next

'    End Sub


'    Protected Sub BntExport_Click(sender As Object, e As EventArgs)

'        Me.SelectButton = sender
'        RaiseEvent Selected(Me.SelectValue)

'    End Sub

'End Class

'Public Class GroupButton(Of tres As {IButtonControl, WebControl})

'    Public Property CacheState As Object
'    Public Property group As String
'    Public Property cssactive As String


'    Private Buttons As New List(Of tres)
'    Private p As Page

'    Public ReadOnly Property SelectValue() As String
'        Get
'            Return Me.SelectButton.CommandArgument
'        End Get
'    End Property

'    Public Property SelectButtonID() As String
'        Get
'            Return Me.CacheState("_GROUP_" & Me.group)
'        End Get
'        Set(ByVal value As String)
'            Me.CacheState("_GROUP_" & Me.group) = value
'        End Set
'    End Property

'    Public Property SelectButton() As tres
'        Get
'            Return (From b In Me.Buttons Where b.ID = Me.SelectButtonID).FirstOrDefault
'        End Get
'        Set(value As tres)
'            Me.SelectButtonID = value.ID

'            SetDataButtonList()

'        End Set
'    End Property

'    Public Event Selected(value As String)


'    Sub New(cache As Object, group As String, cssactive As String)


'        Me.p = HttpContext.Current.CurrentHandler
'        Me.CacheState = cache
'        Me.group = group
'        Me.cssactive = cssactive

'        Buttons = UI.Controls.FindCommandControls(Of tres)(Me.p.Controls, group)

'        For Each b In Buttons
'            AddHandler b.Click, AddressOf BntExport_Click
'        Next
'        SetDataButtonList()

'    End Sub

'    Private Sub SetDataButtonList()

'        For Each b In Buttons
'            UI.Controls.ClassSet(b, cssactive, b.ID = Me.SelectButtonID)
'        Next

'    End Sub


'    Protected Sub BntExport_Click(sender As Object, e As EventArgs)

'        Me.SelectButton = sender
'        RaiseEvent Selected(Me.SelectValue)

'    End Sub

'End Class







